{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as py\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>info_id</th>\n",
       "      <th>emp_id</th>\n",
       "      <th>number_consumers</th>\n",
       "      <th>mode</th>\n",
       "      <th>dining_table_id</th>\n",
       "      <th>dining_table_name</th>\n",
       "      <th>expenditure</th>\n",
       "      <th>dishes_count</th>\n",
       "      <th>accounts_payable</th>\n",
       "      <th>use_start_time</th>\n",
       "      <th>...</th>\n",
       "      <th>lock_time</th>\n",
       "      <th>cashier_id</th>\n",
       "      <th>pc_id</th>\n",
       "      <th>order_number</th>\n",
       "      <th>org_id</th>\n",
       "      <th>print_doc_bill_num</th>\n",
       "      <th>lock_table_info</th>\n",
       "      <th>order_status</th>\n",
       "      <th>phone</th>\n",
       "      <th>name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>417</td>\n",
       "      <td>1442</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1501</td>\n",
       "      <td>1022</td>\n",
       "      <td>165</td>\n",
       "      <td>5</td>\n",
       "      <td>165</td>\n",
       "      <td>2016/8/1 11:05:36</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/1 11:11:46</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880641</td>\n",
       "      <td>苗宇怡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>301</td>\n",
       "      <td>1095</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1430</td>\n",
       "      <td>1031</td>\n",
       "      <td>321</td>\n",
       "      <td>6</td>\n",
       "      <td>321</td>\n",
       "      <td>2016/8/1 11:15:57</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/1 11:31:55</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>328</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880174</td>\n",
       "      <td>赵颖</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>413</td>\n",
       "      <td>1147</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1488</td>\n",
       "      <td>1009</td>\n",
       "      <td>854</td>\n",
       "      <td>15</td>\n",
       "      <td>854</td>\n",
       "      <td>2016/8/1 12:42:52</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/1 12:54:37</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880276</td>\n",
       "      <td>徐毅凡</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>415</td>\n",
       "      <td>1166</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1502</td>\n",
       "      <td>1023</td>\n",
       "      <td>466</td>\n",
       "      <td>10</td>\n",
       "      <td>466</td>\n",
       "      <td>2016/8/1 12:51:38</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/1 13:08:20</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880231</td>\n",
       "      <td>张大鹏</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>392</td>\n",
       "      <td>1094</td>\n",
       "      <td>10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1499</td>\n",
       "      <td>1020</td>\n",
       "      <td>704</td>\n",
       "      <td>24</td>\n",
       "      <td>704</td>\n",
       "      <td>2016/8/1 12:58:44</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/1 13:07:16</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880173</td>\n",
       "      <td>孙熙凯</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>940</td>\n",
       "      <td>641</td>\n",
       "      <td>1095</td>\n",
       "      <td>8</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1492</td>\n",
       "      <td>1013</td>\n",
       "      <td>679</td>\n",
       "      <td>12</td>\n",
       "      <td>679</td>\n",
       "      <td>2016/8/31 21:23:48</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/31 21:31:48</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880307</td>\n",
       "      <td>李靖</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>941</td>\n",
       "      <td>672</td>\n",
       "      <td>1089</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1489</td>\n",
       "      <td>1010</td>\n",
       "      <td>800</td>\n",
       "      <td>24</td>\n",
       "      <td>800</td>\n",
       "      <td>2016/8/31 21:24:12</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/31 21:56:12</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880305</td>\n",
       "      <td>莫言</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>942</td>\n",
       "      <td>692</td>\n",
       "      <td>1155</td>\n",
       "      <td>8</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1492</td>\n",
       "      <td>1013</td>\n",
       "      <td>735</td>\n",
       "      <td>10</td>\n",
       "      <td>735</td>\n",
       "      <td>2016/8/31 21:25:18</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/31 21:33:34</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880327</td>\n",
       "      <td>习一冰</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>943</td>\n",
       "      <td>647</td>\n",
       "      <td>1094</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1485</td>\n",
       "      <td>1006</td>\n",
       "      <td>262</td>\n",
       "      <td>9</td>\n",
       "      <td>262</td>\n",
       "      <td>2016/8/31 21:37:39</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/31 21:55:39</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880207</td>\n",
       "      <td>章春华</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>944</td>\n",
       "      <td>570</td>\n",
       "      <td>1113</td>\n",
       "      <td>8</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1517</td>\n",
       "      <td>1038</td>\n",
       "      <td>589</td>\n",
       "      <td>13</td>\n",
       "      <td>589</td>\n",
       "      <td>2016/8/31 21:41:56</td>\n",
       "      <td>...</td>\n",
       "      <td>2016/8/31 21:32:56</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>330</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>18688880313</td>\n",
       "      <td>唐雅嘉</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>945 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     info_id  emp_id  number_consumers  mode  dining_table_id  \\\n",
       "0        417    1442                 4   NaN             1501   \n",
       "1        301    1095                 3   NaN             1430   \n",
       "2        413    1147                 6   NaN             1488   \n",
       "3        415    1166                 4   NaN             1502   \n",
       "4        392    1094                10   NaN             1499   \n",
       "..       ...     ...               ...   ...              ...   \n",
       "940      641    1095                 8   NaN             1492   \n",
       "941      672    1089                 6   NaN             1489   \n",
       "942      692    1155                 8   NaN             1492   \n",
       "943      647    1094                 4   NaN             1485   \n",
       "944      570    1113                 8   NaN             1517   \n",
       "\n",
       "     dining_table_name  expenditure  dishes_count  accounts_payable  \\\n",
       "0                 1022          165             5               165   \n",
       "1                 1031          321             6               321   \n",
       "2                 1009          854            15               854   \n",
       "3                 1023          466            10               466   \n",
       "4                 1020          704            24               704   \n",
       "..                 ...          ...           ...               ...   \n",
       "940               1013          679            12               679   \n",
       "941               1010          800            24               800   \n",
       "942               1013          735            10               735   \n",
       "943               1006          262             9               262   \n",
       "944               1038          589            13               589   \n",
       "\n",
       "         use_start_time  ...           lock_time cashier_id  pc_id  \\\n",
       "0     2016/8/1 11:05:36  ...   2016/8/1 11:11:46        NaN    NaN   \n",
       "1     2016/8/1 11:15:57  ...   2016/8/1 11:31:55        NaN    NaN   \n",
       "2     2016/8/1 12:42:52  ...   2016/8/1 12:54:37        NaN    NaN   \n",
       "3     2016/8/1 12:51:38  ...   2016/8/1 13:08:20        NaN    NaN   \n",
       "4     2016/8/1 12:58:44  ...   2016/8/1 13:07:16        NaN    NaN   \n",
       "..                  ...  ...                 ...        ...    ...   \n",
       "940  2016/8/31 21:23:48  ...  2016/8/31 21:31:48        NaN    NaN   \n",
       "941  2016/8/31 21:24:12  ...  2016/8/31 21:56:12        NaN    NaN   \n",
       "942  2016/8/31 21:25:18  ...  2016/8/31 21:33:34        NaN    NaN   \n",
       "943  2016/8/31 21:37:39  ...  2016/8/31 21:55:39        NaN    NaN   \n",
       "944  2016/8/31 21:41:56  ...  2016/8/31 21:32:56        NaN    NaN   \n",
       "\n",
       "     order_number  org_id  print_doc_bill_num  lock_table_info  order_status  \\\n",
       "0             NaN     330                 NaN              NaN             1   \n",
       "1             NaN     328                 NaN              NaN             1   \n",
       "2             NaN     330                 NaN              NaN             1   \n",
       "3             NaN     330                 NaN              NaN             1   \n",
       "4             NaN     330                 NaN              NaN             1   \n",
       "..            ...     ...                 ...              ...           ...   \n",
       "940           NaN     330                 NaN              NaN             1   \n",
       "941           NaN     330                 NaN              NaN             1   \n",
       "942           NaN     330                 NaN              NaN             1   \n",
       "943           NaN     330                 NaN              NaN             1   \n",
       "944           NaN     330                 NaN              NaN             1   \n",
       "\n",
       "           phone  name  \n",
       "0    18688880641   苗宇怡  \n",
       "1    18688880174    赵颖  \n",
       "2    18688880276   徐毅凡  \n",
       "3    18688880231   张大鹏  \n",
       "4    18688880173   孙熙凯  \n",
       "..           ...   ...  \n",
       "940  18688880307    李靖  \n",
       "941  18688880305    莫言  \n",
       "942  18688880327   习一冰  \n",
       "943  18688880207   章春华  \n",
       "944  18688880313   唐雅嘉  \n",
       "\n",
       "[945 rows x 21 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A = pd.read_csv('D:/Desktop/meal_order_info.csv',encoding='gbk')\n",
    "type(A)\n",
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(A.iloc[:,11])\n",
    "# A.iloc[:,11]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['2016/8/1 11:11:46',\n",
       " '2016/8/1 11:31:55',\n",
       " '2016/8/1 12:54:37',\n",
       " '2016/8/1 13:08:20',\n",
       " '2016/8/1 13:07:16']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B = [i for i in A.iloc[:5,11] ]\n",
    "type(B)\n",
    "B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1470028036.0\n"
     ]
    }
   ],
   "source": [
    "for i in B:\n",
    "    d = time.strptime(i, \"%Y/%m/%d %H:%M:%S\")\n",
    "    d = time.mktime(d)\n",
    "    \n",
    "print(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n",
      "8\n",
      "8\n",
      "8\n",
      "8\n"
     ]
    }
   ],
   "source": [
    "for i in B:\n",
    "    B1=pd.Timestamp(i).month\n",
    "    print(B1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#coding:UTF-8\n",
    "import time\n",
    "\n",
    "dt = \"2016/8/1 11:11:46\"\n",
    "#2016-8-1 11:11:46\n",
    "\n",
    "#转换成时间数组\n",
    "timeArray = time.strptime(dt, \"%Y/%m/%d %H:%M:%S\")\n",
    "#转换成时间戳\n",
    "timestamp = time.mktime(timeArray)\n",
    "\n",
    "print (timestamp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "#获得当前时间\n",
    "now = datetime.datetime.now()  ->这是时间数组格式\n",
    "#转换为指定的格式:\n",
    "otherStyleTime = now.strftime(\"%Y-%m-%d %H:%M:%S\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "ename": "OSError",
     "evalue": "[Errno 22] Invalid argument",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mOSError\u001b[0m                                   Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-23-0cfe9d1a46ba>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;31m#转换成localtime\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m \u001b[0mtime_local\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlocaltime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtimestamp\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      7\u001b[0m \u001b[1;31m#转换成新的时间格式(2016-05-05 20:28:54)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      8\u001b[0m \u001b[0mdt\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstrftime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"%Y-%m-%d %H:%M:%S\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mtime_local\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mOSError\u001b[0m: [Errno 22] Invalid argument"
     ]
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "timestamp = -123456\n",
    "\n",
    "#转换成localtime\n",
    "time_local = time.localtime(timestamp)\n",
    "#转换成新的时间格式(2016-05-05 20:28:54)\n",
    "dt = time.strftime(\"%Y-%m-%d %H:%M:%S\",time_local)\n",
    "\n",
    "dt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
